<%@ page language="java" import="java.util.*,com.entity.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
  <head>
    <title>单位选择</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.cookie.js" type="text/javascript"></script>
    <script src="js/jquery.treeview.js" type="text/javascript"></script>
    <script src="js/permtree.js" type="text/javascript"></script>
    <link rel="stylesheet" href="css/jquery.treeview.css" />
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <style type="text/css">
     li a {
            font-size:12px;
   			outline:none;
		}
	 li a:hover
	  {
	     font-size:16px;
	     background-color:#CCCCCC;
	  }
    </style>
    <script>
	$(document).ready(function(){
	$("#browser").treeview();
	$("#browser").permtree(); 
});

  function clickthis1(id,str)
  {
         var sid = document.getElementById("sid").value;
         var _parentWin = parent.opener ;
         if(sid==1)
         {
	     _parentWin.document.getElementById("bmbh").value = id ; 
	     _parentWin.document.getElementById("bm").value=str;
	     }
	     if(sid==2)
	     {
	        _parentWin.document.getElementById("bmbh1").value = id ; 
	        _parentWin.document.getElementById("bm1").value=str;
	     }
  }
  
   function clickthis(str,id1,str1)
  {
         var sid = document.getElementById("sid").value;
         var _parentWin = parent.opener ;
         if(sid==1)
         {
	     _parentWin.document.getElementById("bmbh").value = id1 ; 
	     _parentWin.document.getElementById("bm").value=str+" "+str1;
	     }
	     if(sid==2)
	     {
	        _parentWin.document.getElementById("bmbh1").value = id1 ; 
	        _parentWin.document.getElementById("bm1").value=str+" "+str1;
	     }
  }
  function tb_remove()
  {
      window.top.close();
  }
    </script>
  </head>
  
  <body>
  <table class="TableTop" width="100%">
   <tbody><tr>
      <td class="left"></td>
      <td class="center subject">
         部门选择</td>
      <td class="right"></td>
   </tr>
     </tbody></table>

  <table width="100%" border="1" cellspacing="0" cellpadding="5">
    <tr>
    <%String sid =request.getParameter("sid"); 
      String pd = request.getParameter("pd");
    %>
    <input type="hidden" value="<%=sid %>" id=sid name=sid/>
      <td>
      <ul id="browser">
       <%Dlyh dlyh = (Dlyh)request.getSession().getAttribute("dlyh"); 
         if(dlyh.getZd().getTypename().equals("邯郸市")){%>
            <li><a href="javascript:void(0)" onClick="clickthis1(533,'邯郸市')" >邯郸市</a>
        	<ul>
        	   <!-- 县 -->
            	<% List list = (List)request.getSession().getAttribute("xianlist");
            	if(list!=null && list.size()>0){
            	    Iterator it = list.iterator();
            	    while(it.hasNext())
            	    {
            	       Zd zd = (Zd)it.next();
            	       if(zd.getParentid().equals(dlyh.getZd().getId())){
            	   %>
            	  <li class="closed">
				   <a href="javascript:void(0);" onClick="clickthis1(<%=zd.getId() %>,'<%=zd.getTypename() %>')"><%=zd.getTypename() %></a>
                	<%if(pd.trim().equals("")){ %>
                	<ul>
                	<!-- 乡 -->
                    	<%
                    	 List xianglist = (List)request.getSession().getAttribute("xianglist");
                    	 Iterator cit =xianglist.iterator();
                    	while(cit.hasNext())
                    	 {
                    	    Zd z=(Zd)cit.next();
                    	    if(zd.getId().equals(z.getParentid()))
                    	    {
                    	     System.out.println(z.getTypename()+"   "+z.getId()+"  "+zd.getId());
                    	 %>
                    	<li class="closed">
                    	<a href="javascript:void(0);" onClick="clickthis('<%=zd.getTypename() %>',<%=z.getId() %>,'<%=z.getTypename() %>')"><%=z.getTypename() %></a>
                    	   <ul>
                    	   <!-- 村 -->
                    	<%
                    	 List cunlist = (List)request.getSession().getAttribute("cunlist");
                    	 System.out.println(cunlist.size()+"长度是：***");
                    	 Iterator csit =cunlist.iterator();
                    	 while(csit.hasNext())
                    	 {
                    	    Zd zs=(Zd)csit.next();
                    	    if(z.getId().equals(zs.getParentid()))
                    	    {
                    	     System.out.println(zs.getTypename()+"   "+zs.getId()+"  "+zd.getId());
                    	 %>
                    	<li class="closed">
                    	<a href="javascript:void(0);" onClick="clickthis('<%=z.getTypename() %>',<%=zs.getId() %>,'<%=zs.getTypename() %>')"><%=zs.getTypename() %></a>
                    	  
                        </li>
                        <%} }%>
                    </ul>
                        </li>
                        <%}} }%>
                    </ul>
                    <%} %>
                </li> 
         <%}}}
         else {
         %>
    	<li><a href="javascript:void(0)" onClick="clickthis1(<%=dlyh.getZd().getId() %>,'<%=dlyh.getZd().getTypename() %>')" ><%=dlyh.getZd().getTypename() %></a>
        	<ul>
            	<% List lists = (List)request.getSession().getAttribute("xianglist");
            	if(lists!=null && lists.size()>0){
            	    Iterator its = lists.iterator();
            	    while(its.hasNext())
            	    {
            	       Zd zds = (Zd)its.next();
            	   %>
            	  <li class="closed">
				   <a href="javascript:void(0);" onClick="clickthis1(<%=zds.getId() %>,'<%=zds.getTypename() %>')"><%=zds.getTypename() %></a>
                	<%if(pd.trim().equals("")){ %>
                	<ul>
                    	<%
                    	 List cunlists = (List)request.getSession().getAttribute("cunlist");
                    	 if(cunlists!=null &&cunlists.size()>0){
                    	 Iterator cits =cunlists.iterator();
                    	while(cits.hasNext())
                    	 {
                    	    Zd zs=(Zd)cits.next();
                    	    if(zds.getId().equals(zs.getParentid()))
                    	    {
                    	     System.out.println(zs.getTypename()+"   "+zs.getId()+"  "+zds.getId());
                    	 %>
                    	<li class="closed">
                    	<a href="javascript:void(0);" onClick="clickthis('<%=zds.getTypename() %>',<%=zs.getId() %>,'<%=zs.getTypename() %>')"><%=zs.getTypename() %></a>
                        </li>
                        <%} }}
                        System.out.println(cunlists.size()+"长度wie：************");
                        %>
                    </ul>
                    <%} %>
                </li>
			<%} }
			
        } %>
    </ul></td>
    </tr>
    <tr>
      <td align="center"><input name="button" type="submit" value="确定"  onclick="tb_remove()"  />　　</td>
    </tr>
  </table>

</body>
</html>
